<template>
    <div>
        <a-date-picker @change="onChange" :value="tempValue" style="width: 200px;" :disabledDate="disabledDate"
            :allowClear="false" />
    </div>
</template>
<script>
import moment from 'moment';
export default {
    name: 'ZsSelectData',
    props: {
        menuId: {
            type: [String, Number],
            default: '',
        },
        formData: {
            type: Object,
            default: () => { }
        },
        dataIndex: {
            type: String,
            default: 'startTime',
        },
        onCallBack: {
            type: Function,
            default: () => { }
        },
        type: {
            type: String,
        }
    },
    data() {
        return {
            value: null,
            dateFormat: 'YYYY-MM-DD'
        }
    },
    methods: {
        onChange(a, b) {
            this.value = b;
            this.onCallBack(b, this.dataIndex);
        },
        disabledDate(cur) {
            if (this.type == 'pptList') {
                return false;
            } else {
                return cur && moment(cur).format("YYYY-MM-DD") > moment().format("YYYY-MM-DD");
            }
        }
    },
    computed: {
        tempValue() {
            let res = null;
            if (this.value) {
                res = moment(this.value, this.dateFormat);
            }
            return res;
        }
    },
    watch: {
        formData: {
            handler(nVal, oVal) {
                this.value = nVal[this.dataIndex] || null
            },
            deep: true,
        }
    }
}
</script>
<style lang="less" scoped></style>